package org.shiwen.week3.answer;

import java.util.Scanner;

public class GuessNumPlus {
    public static void main(String[] args) {
        int random = (int) (Math.random() * 100);
        int guess = -1;
        int min = 0;
        int max = 100;
        Scanner sc = new Scanner(System.in);
        while (true) {
            if (guess < min || guess > max) {
                System.out.println("请输入一个"+min+"到"+max+"的数字");
                guess = sc.nextInt();
            } else if (guess == random) {
                System.out.println("你猜对了");
                break;
            } else if (guess > random) {
                max = guess-1;
                System.out.println("大了");
            } else {
                min = guess+1;
                System.out.println("小了");
            }
        }
    }
}
